from django.urls import path, include

from s3.views import MainHostViewSet, LocationHostViewSet, PathBucketHostViewSet, PathObjHostViewSet
from .routers import NoDetailRouter

router = NoDetailRouter(trailing_slash=False)
router.register(r'', MainHostViewSet, basename='main-host')

router.register(r'(?P<bucket_name>[\w-]+)?(?P<location>)', LocationHostViewSet, basename='location-host')   # http://host/bucket?location version list-type ...
router.register(r'(?P<bucket_name>[\w-]+)/?(?P<location>)', LocationHostViewSet, basename='location-host_slash')    # http://host/bucket/?location 或  http://host/bucket?location=

router.register(r'(?P<bucket_name>[\w-]+)/.+', PathObjHostViewSet, basename='path-obj-host')
router.register(r'.+', PathBucketHostViewSet, basename='path-bucket-host')  # s3 path-style 测试 有的是结尾 / ，有的没有


urlpatterns = [
    path('', include(router.urls)),
]
